package top.xia17.plugins.fast.common.mail;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.mail.internet.MimeMessage;

/**
 * 邮箱自动配置类
 *
 * @author xia17
 * @date 2022/4/6
 */
@Configuration
@ConditionalOnClass(MimeMessage.class)
@Slf4j
public class Xia17MailAutoconfiguration {


    /**
     * 邮箱配置文件
     *
     * @return /
     */
    @Bean
    @ConfigurationProperties(prefix = "xia17fast.common.mail")
    public Xia17MailProperties mailProperties() {
        return new Xia17MailProperties();
    }

    /**
     * 发送邮件工具类
     *
     * @return /
     */
    @Bean
    public Xia17MailUtil mailUtil() {
        return new Xia17MailUtil(mailProperties());
    }


}
